///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
#ifndef __TIMER_H__
#define __TIMER_H__

#include <Config.h>
#ifdef WIN32   // Windows system specific
#include <windows.h>
#else          // Unix based system specific
#include <sys/time.h>
#endif

//-----------------------------------------------------------------------------

class Timer
{
public:
    Timer();                                    // default constructor
    ~Timer();                                   // default destructor

    void	start();                             // start timer
    void	stop();                              // stop the timer

	f64		getStartTimeInSec();
	f64		getStartTimeInMilliSec();
	f64		getStartTimeInMicroSec();

	f64		getEndTimeInSec();
	f64		getEndTimeInMilliSec();
	f64		getEndTimeInMicroSec();

	f64		getElapsedTime();                    // get elapsed time in second
    f64		getElapsedTimeInSec();               // get elapsed time in second (same as getElapsedTime)
    f64		getElapsedTimeInMilliSec();          // get elapsed time in milli-second
    f64		getElapsedTimeInMicroSec();          // get elapsed time in micro-second
    
	void	sleepTime(u32 sec);
	void	sleepTimeInSec(u32 sec);
	void	sleepTimeInMilliSec(u32 msec);
	void	sleepTimeInMicroSec(u32 usec);

private:
    f64		startTimeInMicroSec;                 // starting time in micro-second
    f64		endTimeInMicroSec;                   // ending time in micro-second
    int		stopped;                             // stop flag 
#ifdef WIN32
    LARGE_INTEGER frequency;                    // ticks per second
    LARGE_INTEGER startCount;                   //
    LARGE_INTEGER endCount;                     //
#else
    timeval startCount;                         //
    timeval endCount;                           //
#endif
};

#endif	//	__TIMER_H__
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
